<?php

//created 6/14/12
echo "<br>My Wars</br>";


if (isset($war_data)) {
    
    foreach ($war_data as $row) {
        $me = $_SESSION["active_character"];
        if ($row->getAttacker() == $me) {
            echo "<br>aWar: " . $row->getId() . ", attacker " . $row->getAttacker() . ", defender: " . $row->getDefender() . ", precentage: " . $row->getPercentage() . ", which claim: " . $row->getWhichClaim();
        }else {
            echo "<br>dWar: " . $row->getId() . ", attacker " . $row->getAttacker() . ", defender: " . $row->getDefender() . ", precentage: " . $row->getPercentage() . ", which claim: " . $row->getWhichClaim();
        }
        
        
    } // end foreach $war_data
    
    if (isset($army_data)) {
        
        foreach ($army_data as $row) {
            
            echo "<br>Army: " . $row->getId() . ".</br>";
        }
        
    }
    
    
    if (isset($armyforces_data)) {
        $highest_leadership = '0';
        $total_soldiers = '0';
        foreach ($armyforces_data as $row) {
            
            echo "<br>Army force: ";
            $leadership = $row->getLeadership();
            if ($leadership > $highest_leadership) {
                $highest_leadership = $leadership;
                $best_leader_id = $row->getAttachedNoble();
                echo "attached noble: " . $row->getAttachedNoble() . ", leadership " . $row->getLeadership() . "</br>";
            } else {
                $soldiers = $row->getSoldiers();
                $total_soldiers = $total_soldiers + $soldiers;
                echo $row->getSoldiers() . " soldiers from region# " . $row->getSoldiersFrom() . "</br>";
            }
            
        }
        
    }
    
}  /// end if isset war_data
else {
    echo "No wars.";
}